import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:pornhub_app/model/video_base_model.dart';
import 'package:pornhub_app/routes/routes.dart';
import 'package:pornhub_app/utils/extension.dart';
import 'package:pornhub_app/utils/logger.dart';
import 'package:pornhub_app/views/mine/mine_releases/mine_release_brushvideo_controller.dart';

import '../../../../components/no_more/no_data.dart';
import '../../douyin/short_video_list_cell.dart';

class MinesReleaseBrushVideoPage
    extends GetView<MineReleaseBrushVideoController> {
  final int videoStatus; //1-待审核 2-已发布 3-未通过

  const MinesReleaseBrushVideoPage({super.key, required this.videoStatus});

  @override
  Widget build(BuildContext context) {
    logger.d(videoStatus);
    return EasyRefresh(
      refreshOnStart: true,
      controller: controller.refreshController,
      onRefresh: () {
        controller.onRefresh(videoStatus);
      },
      onLoad: () {
        controller.onLoad();
      },
      child: PagedGridView<int, VideoBaseModel>(
        padding: EdgeInsets.only(top: 10, left: 14.w, right: 14.w),
        addAutomaticKeepAlives: true,
        pagingController: controller.pagingControllers,
        builderDelegate: PagedChildBuilderDelegate<VideoBaseModel>(
          firstPageProgressIndicatorBuilder: (context) =>
              const SizedBox.shrink(),
          newPageProgressIndicatorBuilder: (context) => const SizedBox.shrink(),
          noMoreItemsIndicatorBuilder: (context) => const SizedBox.shrink(),
          noItemsFoundIndicatorBuilder: (context) => const NoData(),
          itemBuilder: (context, item, index) => ShortVideoListCell(
            model: item,
            width: 182.w,
            titleColor: Colors.white,
            check: true,
            checkStatus: videoStatus,
          ).onTap(() => controller.onclickItem(index)),
        ),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            mainAxisSpacing: 10.w,
            crossAxisSpacing: 8.w,
            crossAxisCount: 2,
            childAspectRatio: 182 / 300),
      ),
    );
  }
}
